From: Keir Fraser Date: Thu, 30 Oct 2008 13:33:17 +0000 (+0000) Subject: CPUIDLE: add idx field X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14054^2~10 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=667e7ffd98886856298fe6780aeb410b5a89552a;p=xen.git CPUIDLE: add idx field This patch adds an idx field in the 'struct acpi_processor_cx'. It can simplify some coding lines. Signed-off-by: Guanqun Lu Signed-off-by: Wei Gang = --- diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index 176129489e..eda2d9b21a 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -75,13 +75,14 @@ static void print_acpi_power(uint32_t cpu, struct acpi_processor_power *power) printk("==cpu%d==\n", cpu); printk("active state:\t\tC%d\n", - power->last_state ? (int)(power->last_state - power->states) : -1); + power->last_state ? power->last_state->idx : -1); printk("max_cstate:\t\tC%d\n", max_cstate); printk("states:\n"); for ( i = 1; i < power->count; i++ ) { - printk((power->last_state == &power->states[i]) ? " *" : " "); + printk((power->last_state && power->last_state->idx == i) ? + " *" : " "); printk("C%d:\t", i); printk("type[C%d] ", power->states[i].type); printk("latency[%03d] ", power->states[i].latency); @@ -222,7 +223,7 @@ static void acpi_processor_idle(void) if ( power->flags.bm_check && acpi_idle_bm_check() && cx->type == ACPI_STATE_C3 ) cx = power->safe_state; - if ( cx - &power->states[0] > max_cstate ) + if ( cx->idx > max_cstate ) cx = &power->states[max_cstate]; } if ( !cx ) @@ -328,7 +329,7 @@ static void acpi_processor_idle(void) } /* Trace cpu idle entry */ - TRACE_1D(TRC_PM_IDLE_ENTRY, cx - &power->states[0]); + TRACE_1D(TRC_PM_IDLE_ENTRY, cx->idx); /* * Before invoking C3, be aware that TSC/APIC timer may be * stopped by H/W. Without carefully handling of TSC/APIC stop issues, @@ -349,7 +350,7 @@ static void acpi_processor_idle(void) /* recovering TSC */ cstate_restore_tsc(); /* Trace cpu idle exit */ - TRACE_1D(TRC_PM_IDLE_EXIT, cx - &power->states[0]); + TRACE_1D(TRC_PM_IDLE_EXIT, cx->idx); if ( power->flags.bm_check && power->flags.bm_control ) { @@ -387,8 +388,13 @@ static void acpi_processor_idle(void) static int init_cx_pminfo(struct acpi_processor_power *acpi_power) { + int i; + memset(acpi_power, 0, sizeof(*acpi_power)); + for ( i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++ ) + acpi_power->states[i].idx = i; + acpi_power->states[ACPI_STATE_C1].type = ACPI_STATE_C1; acpi_power->states[ACPI_STATE_C0].valid = 1; @@ -761,8 +767,7 @@ int pmstat_get_cx_stat(uint32_t cpuid, struct pm_cx_stat *stat) return 0; } - stat->last = (power->last_state) ? - (int)(power->last_state - &power->states[0]) : 0; + stat->last = power->last_state ? power->last_state->idx : 0; stat->nr = power->count; stat->idle_time = v->runstate.time[RUNSTATE_running]; if ( v->is_running ) diff --git a/xen/include/xen/cpuidle.h b/xen/include/xen/cpuidle.h index 32d71d15f3..ccfae6c4d3 100644 --- a/xen/include/xen/cpuidle.h +++ b/xen/include/xen/cpuidle.h @@ -32,6 +32,7 @@ struct acpi_processor_cx { + u8 idx; u8 valid; u8 type; u32 address;